#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2019/1/4 13:21
# @Author  : lizhen
# @Site    : 
# @File    : cFork.py
# @Software: PyCharm
import time
import os


class ForkDemo:
    def judge_parent_child(self):
        """
        fd = ForkDemo()
        fd.judge_parent_child()
        """
        # 创建子进程前声明的变量
        number = 7
        try:
            # SYSTEMDIFF windows下没有os.fork
            pid = os.fork()
            if pid == 0:
                print("this is child process")
                number = number - 1
                time.sleep(5)
                print(number)
            else:
                print("this is parent process")
        except OSError as e:
            pass


if __name__ == '__main__':
    fd = ForkDemo()
    fd.judge_parent_child()
